package cn.jinjie.day05.test8;

public class Demo4 {
    public static void main(String[] args) {
        System.out.println(sum(4));
        System.out.println(up(5));
    }

    public static int sum(int n) {
        if (n == 1) {
            return 1;
        } else {
            return n + sum(n - 1);
        }
    }

    public static int up(int num) {
        if (num == 1 || num == 2) {
            return num;
        } else {
            return up(num - 1) + up(num - 2);
        }
    }
}
